package com.ruoyi.project.jiaqin.newscommentlikers.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.newscommentlikers.domain.NewsCommentLikers;
import com.ruoyi.project.jiaqin.newscommentlikers.service.INewsCommentLikersService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户新闻评论点赞Controller
 * 
 * @author LCL
 * @date 2021-11-09
 */
@Controller
@RequestMapping("/jiaqin/newscommentlikers")
public class NewsCommentLikersController extends BaseController
{
    private String prefix = "jiaqin/newscommentlikers";

    @Autowired
    private INewsCommentLikersService newsCommentLikersService;

    @RequiresPermissions("jiaqin:newscommentlikers:view")
    @GetMapping()
    public String newscommentlikers()
    {
        return prefix + "/newscommentlikers";
    }

    /**
     * 查询用户新闻评论点赞列表
     */
    @RequiresPermissions("jiaqin:newscommentlikers:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(NewsCommentLikers newsCommentLikers)
    {
        startPage();
        List<NewsCommentLikers> list = newsCommentLikersService.selectNewsCommentLikersList(newsCommentLikers);
        return getDataTable(list);
    }

    /**
     * 导出用户新闻评论点赞列表
     */
    @RequiresPermissions("jiaqin:newscommentlikers:export")
    @Log(title = "用户新闻评论点赞", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(NewsCommentLikers newsCommentLikers)
    {
        List<NewsCommentLikers> list = newsCommentLikersService.selectNewsCommentLikersList(newsCommentLikers);
        ExcelUtil<NewsCommentLikers> util = new ExcelUtil<NewsCommentLikers>(NewsCommentLikers.class);
        return util.exportExcel(list, "newscommentlikers");
    }

    /**
     * 新增用户新闻评论点赞
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户新闻评论点赞
     */
    @RequiresPermissions("jiaqin:newscommentlikers:add")
    @Log(title = "用户新闻评论点赞", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(NewsCommentLikers newsCommentLikers)
    {
        return toAjax(newsCommentLikersService.insertNewsCommentLikers(newsCommentLikers));
    }

    /**
     * 修改用户新闻评论点赞
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        NewsCommentLikers newsCommentLikers = newsCommentLikersService.selectNewsCommentLikersById(id);
        mmap.put("newsCommentLikers", newsCommentLikers);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户新闻评论点赞
     */
    @RequiresPermissions("jiaqin:newscommentlikers:edit")
    @Log(title = "用户新闻评论点赞", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(NewsCommentLikers newsCommentLikers)
    {
        return toAjax(newsCommentLikersService.updateNewsCommentLikers(newsCommentLikers));
    }

    /**
     * 删除用户新闻评论点赞
     */
    @RequiresPermissions("jiaqin:newscommentlikers:remove")
    @Log(title = "用户新闻评论点赞", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(newsCommentLikersService.deleteNewsCommentLikersByIds(ids));
    }
}
